﻿//********************************************************************************//
//创建日期：<创建日期，2010-08-02>
//创建作者：<王一飞，wangyifei@shanghai3h.com>
//功能说明：WTB_LIANXIXX实体层次
//********************************************************************************//
#region Entity
namespace Entity
{
    using System;
    using System.Xml;
    [Serializable()]
    public class WTB_LIANXIXX
    {

        private int m_dec_id;
        /// <summary>
        /// 
        /// </summary>
        public int ID { get { return m_dec_id; } set { m_dec_id = value; } }

        private string m_str_s_zhubiaobh;
        /// <summary>
        /// 
        /// </summary>
        public string S_ZHUBIAOBH { get { return m_str_s_zhubiaobh; } set { m_str_s_zhubiaobh = value; } }

        private string m_str_incident_id;
        /// <summary>
        /// 
        /// </summary>
        public string INCIDENT_ID { get { return m_str_incident_id; } set { m_str_incident_id = value; } }

        private string m_str_con_name;
        /// <summary>
        /// 联系人姓名
        /// </summary>
        public string CON_NAME { get { return m_str_con_name; } set { m_str_con_name = value; } }

        private string m_str_con_value;
        /// <summary>
        /// 联系电话
        /// </summary>
        public string CON_VALUE { get { return m_str_con_value; } set { m_str_con_value = value; } }

        private string m_str_email;
        /// <summary>
        /// 电子邮箱
        /// </summary>
        public string EMAIL { get { return m_str_email; } set { m_str_email = value; } }
        public WTB_LIANXIXX()
        {
        }
    }
}
#endregion
#region EntityProcess
namespace Access.BLL
{
    using System;
    using System.Data;
    //using System.Data.OracleClient;
    using Entity;
    using System.Configuration;
    using System.Data.Common;
    using Platform.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    using Oracle.DataAccess;
    public class WTB_LIANXIXXProcess
    {
        #region Field
        protected string conn;
        #endregion
        #region Construction
        public WTB_LIANXIXXProcess() { conn = Platform.Configuration.ConfigHelper.BusinessConnString; }
        #endregion
        #region public

        /// <summary>
        /// 根据WTB_LIANXIXX实体添加或者修改WTB_LIANXIXX信息
        /// </summary>
        public bool InsertOrUpdate(WTB_LIANXIXX WTB_LIANXIXX, OracleTransaction Transaction)
        {
            if (WTB_LIANXIXX.ID == 0)
            {
                InsertWTB_LIANXIXX(WTB_LIANXIXX, Transaction);
            }
            else
            {
                UpdateWTB_LIANXIXX(WTB_LIANXIXX, Transaction);
            }
            return WTB_LIANXIXX.ID == 0 ? false : true;
        }

        /// <summary>
        /// 根据WTB_LIANXIXX实体添加或修改WTB_LIANXIXX信息
        /// </summary>
        public bool InsertOrUpdate(WTB_LIANXIXX WTB_LIANXIXX)
        {
            return InsertOrUpdate(WTB_LIANXIXX, null);
        }



        /// <summary>
        /// 根据WTB_LIANXIXX主键删除WTB_LIANXIXX信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteWTB_LIANXIXX(int ID, OracleTransaction Transaction)
        {
            string spName = "CS_DelWTB_LIANXIXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据WTB_LIANXIXX主键删除WTB_LIANXIXX信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteWTB_LIANXIXX(int ID)
        {
            return DeleteWTB_LIANXIXX(ID, null);
        }

        /// <summary>
        /// 根据条件删除WTB_LIANXIXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteWTB_LIANXIXXesDynamic(string WhereClause, OracleTransaction Transaction)
        {
            string spName = "CS_DelWTB_LIANXIXXesDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WhereClause;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据条件删除WTB_LIANXIXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteWTB_LIANXIXXesDynamic(string WhereClause)
        {
            return DeleteWTB_LIANXIXXesDynamic(WhereClause, null);
        }

        /// <summary>
        /// 根据WTB_LIANXIXX主键选择WTB_LIANXIXX信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>WTB_LIANXIXX信息</returns>
        public WTB_LIANXIXX SelectWTB_LIANXIXX(int ID, OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_LIANXIXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            OracleDataReader rd;
            if (Transaction == null)
                rd = OracleHelper.ExecuteReader(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                rd = OracleHelper.ExecuteReader((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (rd.Read())
            {
                WTB_LIANXIXX WTB_LIANXIXX = PopulateWTB_LIANXIXX(rd);
                rd.Close();
                return WTB_LIANXIXX;
            }
            else
                return null;
        }

        /// <summary>
        /// 根据WTB_LIANXIXX主键选择WTB_LIANXIXX信息
        /// </summary>
        /// <returns>WTB_LIANXIXX信息</returns>
        public WTB_LIANXIXX SelectWTB_LIANXIXX(int ID)
        {
            return SelectWTB_LIANXIXX(ID, null);
        }

        /// <summary>
        /// 选择所有WTB_LIANXIXX信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>所有WTB_LIANXIXX信息</returns>
        public DataTable SelectWTB_LIANXIXXesAll(OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_LIANXIXXesAll";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }

        /// <summary>
        /// 选择所有WTB_LIANXIXX信息
        /// </summary>
        /// <returns>所有WTB_LIANXIXX信息</returns>
        public DataTable SelectWTB_LIANXIXXesAll()
        {
            return SelectWTB_LIANXIXXesAll(null);
        }

        /// <summary>
        /// 根据条件选择WTB_LIANXIXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>WTB_LIANXIXX信息</returns>
        public DataTable SelectWTB_LIANXIXXesDynamic(string WhereClause, string OrderByExpression, OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_LIANXIXXesDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择WTB_LIANXIXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <returns>WTB_LIANXIXX信息</returns>
        public DataTable SelectWTB_LIANXIXXesDynamic(string WhereClause, string OrderByExpression)
        {
            return SelectWTB_LIANXIXXesDynamic(WhereClause, OrderByExpression, null);
        }



        /// <summary>
        /// 根据条件选择WTB_LIANXIXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>WTB_LIANXIXX信息</returns>
        public DataTable SelectWTB_LIANXIXXesDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize, OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_LIANXIXXesDynPaged";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            storedParams[2].Value = PageIndex;
            storedParams[3].Value = PageSize;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择WTB_LIANXIXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <returns>WTB_LIANXIXX信息</returns>
        public DataTable SelectWTB_LIANXIXXesDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize)
        {
            return SelectWTB_LIANXIXXesDynamic(WhereClause, OrderByExpression, PageIndex, PageSize, null);
        }

        /// <summary>
        ///根据条件更新WTB_LIANXIXX字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateWTB_LIANXIXXesDynamic(string UpdateValue, string WhereClause, OracleTransaction Transaction)
        {
            int result = 0;
            if (UpdateValue == "" || WhereClause == "")
            {
                return 0;
            }
            string spName = "CS_UpdWTB_LIANXIXXDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            storedParams[0].Value = UpdateValue;
            storedParams[1].Value = WhereClause;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            result = Convert.ToInt32(storedParams[2].Value);
            return result;
        }

        /// <summary>
        ///根据条件更新WTB_LIANXIXX字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateWTB_LIANXIXXesDynamic(string UpdateValue, string WhereClause)
        {
            return UpdateWTB_LIANXIXXesDynamic(UpdateValue, WhereClause, null);
        }


        #endregion
        #region Private

        private int InsertWTB_LIANXIXX(WTB_LIANXIXX WTB_LIANXIXX, OracleTransaction Transaction)
        {
            string spName = "CS_InsWTB_LIANXIXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WTB_LIANXIXX.S_ZHUBIAOBH;
            storedParams[1].Value = WTB_LIANXIXX.INCIDENT_ID;
            storedParams[2].Value = WTB_LIANXIXX.CON_NAME;
            storedParams[3].Value = WTB_LIANXIXX.CON_VALUE;
            storedParams[4].Value = WTB_LIANXIXX.EMAIL;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            WTB_LIANXIXX.ID = Convert.ToInt32(storedParams[5].Value);
            return result;
        }
        private bool UpdateWTB_LIANXIXX(WTB_LIANXIXX WTB_LIANXIXX, OracleTransaction Transaction)
        {
            string spName = "CS_UpdWTB_LIANXIXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WTB_LIANXIXX.S_ZHUBIAOBH;
            storedParams[1].Value = WTB_LIANXIXX.INCIDENT_ID;
            storedParams[2].Value = WTB_LIANXIXX.CON_NAME;
            storedParams[3].Value = WTB_LIANXIXX.CON_VALUE;
            storedParams[4].Value = WTB_LIANXIXX.EMAIL;
            storedParams[5].Value = WTB_LIANXIXX.ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }


        private WTB_LIANXIXX PopulateWTB_LIANXIXX(IDataReader dr)
        {
            WTB_LIANXIXX WTB_LIANXIXX = new WTB_LIANXIXX();
            WTB_LIANXIXX.ID = Convert.ToInt32(dr["ID"].ToString());
            WTB_LIANXIXX.S_ZHUBIAOBH = dr["S_ZHUBIAOBH"] == DBNull.Value ? null : (string)dr["S_ZHUBIAOBH"];
            WTB_LIANXIXX.INCIDENT_ID = dr["INCIDENT_ID"] == DBNull.Value ? null : (string)dr["INCIDENT_ID"];
            WTB_LIANXIXX.CON_NAME = dr["CON_NAME"] == DBNull.Value ? null : (string)dr["CON_NAME"];
            WTB_LIANXIXX.CON_VALUE = dr["CON_VALUE"] == DBNull.Value ? null : (string)dr["CON_VALUE"];
            WTB_LIANXIXX.EMAIL = dr["EMAIL"] == DBNull.Value ? null : (string)dr["EMAIL"];
            return WTB_LIANXIXX;
        }


        private void AddRowNumber(DataTable dt)
        {
            dt.Columns.Add(new DataColumn("RowNumber", typeof(int)));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i][dt.Columns.Count - 1] = i + 1;
            }
        }
        #endregion
    }
}
#endregion